{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "bYB2vAVAj1V0"
   },
   "source": [
    "# Natural Language Querying (NLQ)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using the `.with_natural_query` clause in queries presents the opportunity to describe your query using natural language. The underlying solution (currently using models from OpenAI, local LLM support coming soon) fills the query parameters (weights, filters and other query-time inputs) based on the user's natural language query and runs it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "id": "v-CapXqajKC_"
   },
   "outputs": [],
   "source": [
    "%pip install superlinked==37.5.0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "aR3hmrQHjNsV"
   },
   "source": [
    "## Create your configuration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "id": "_SorgEI8jWZF"
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "from superlinked import framework as sl\n",
    "\n",
    "pd.set_option(\"display.max_colwidth\", 500)\n",
    "\n",
    "\n",
    "class Product(sl.Schema):\n",
    "    id: sl.IdField\n",
    "    description: sl.String\n",
    "    stars: sl.Float\n",
    "    type: sl.String\n",
    "\n",
    "\n",
    "product = Product()\n",
    "\n",
    "description_space = sl.TextSimilaritySpace(text=product.description, model=\"Alibaba-NLP/gte-large-en-v1.5\")\n",
    "rating_maximizer_space = sl.NumberSpace(number=product.stars, min_value=1.0, max_value=5.0, mode=sl.Mode.MAXIMUM)\n",
    "index = sl.Index([description_space, rating_maximizer_space], fields=[product.type])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Define a natural language powered query"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "id": "_SorgEI8jWZF"
   },
   "outputs": [],
   "source": [
    "# fill this with your API key - this will drive param extraction\n",
    "openai_config = sl.OpenAIClientConfig(api_key=os.environ[\"OPEN_AI_API_KEY\"], model=\"gpt-4o\")\n",
    "\n",
    "# it is possible now to add descriptions to a `Param` to aid the parsing of information from natural language queries.\n",
    "text_similar_param = sl.Param(\n",
    "    \"query_text\",\n",
    "    description=(\n",
    "        \"The text in the user's query that is used to search in the products' description.\"\n",
    "        \" Extract info that does not apply to other spaces or params.\"\n",
    "    ),\n",
    ")\n",
    "\n",
    "# Define your query using dynamic parameters for query text and weights.\n",
    "# let's create a base query that we will modify to 2 alternative versions\n",
    "base_query = (\n",
    "    sl.Query(\n",
    "        index,\n",
    "        weights={\n",
    "            description_space: sl.Param(\"description_weight\"),\n",
    "            rating_maximizer_space: sl.Param(\"rating_maximizer_weight\"),\n",
    "        },\n",
    "    )\n",
    "    .find(product)\n",
    "    .similar(\n",
    "        description_space,\n",
    "        text_similar_param,\n",
    "        sl.Param(\"description_similar_clause_weight\"),\n",
    "    )\n",
    "    .select_all()\n",
    "    .limit(sl.Param(\"limit\"))\n",
    "    # we will have our LLM fill them based on our natural language query\n",
    "    .with_natural_query(sl.Param(\"natural_query\"), openai_config)\n",
    ")\n",
    "\n",
    "# optionally you can add descriptions to Params, to help the extraction\n",
    "# you may also explicitly set the possible values for a param. This is\n",
    "# highly encouraged for fields that don't have a CategoricalSimilaritySpace\n",
    "# determining the possible values. Keep in mind NLQ does not see the data, just the config!\n",
    "query = base_query.filter(\n",
    "    product.type\n",
    "    == sl.Param(\n",
    "        \"filter_by_type\",\n",
    "        description=\"Used to only present items that have a specific type\",\n",
    "        options=[\"product\", \"book\"],\n",
    "    )\n",
    ")\n",
    "\n",
    "query_with_default_filter = base_query.filter(\n",
    "    product.type\n",
    "    == sl.Param(\n",
    "        \"filter_by_type\",\n",
    "        description=\"Used to only present items that have a specific type\",\n",
    "        options=[\"product\", \"book\"],\n",
    "        default=\"product\",  # we can add defaults so if the NLQ is not able to fill a Param, it will use this default\n",
    "    )\n",
    ")\n",
    "\n",
    "# it is also possible to refer to a specific item in the VDB by referencing its id\n",
    "with_vector_query = (\n",
    "    sl.Query(\n",
    "        index,\n",
    "        weights={\n",
    "            description_space: sl.Param(\"description_weight\"),\n",
    "            rating_maximizer_space: sl.Param(\"rating_maximizer_weight\"),\n",
    "        },\n",
    "    )\n",
    "    .find(product)\n",
    "    .with_vector(product, sl.Param(\"product_id\"))\n",
    "    .with_natural_query(sl.Param(\"natural_query\"), openai_config)\n",
    "    .limit(sl.Param(\"limit\"))\n",
    "    .select_all()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "YMMq3UdCjgDl"
   },
   "source": [
    "## Load test data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "id": "N4XfRXqSju_Y"
   },
   "outputs": [],
   "source": [
    "# Run the app.\n",
    "source: sl.InMemorySource = sl.InMemorySource(\n",
    "    product,\n",
    "    parser=sl.DataFrameParser(schema=product, mapping={product.id: \"product_id\"}),\n",
    ")\n",
    "executor = sl.InMemoryExecutor(sources=[source], indices=[index])\n",
    "app = executor.run()\n",
    "\n",
    "# Download dataset.\n",
    "df = pd.read_csv(\n",
    "    \"https://storage.googleapis.com/superlinked-sample-datasets/esci_sample.csv\",\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Ingest data to the framework.\n",
    "source.put([df])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Run queries using natural language\n",
    "\n",
    "Filling up params using descriptions of natural language. The only exceptions are:\n",
    "- limit\n",
    "- radius\n",
    "- the input to the natural language query itself.\n",
    "If you are using CustomSpace, make sure to provide the search vector explicitly!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Params without default value set by the user"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 363
    },
    "id": "vFhhcr6Tj6rm",
    "outputId": "956c3903-08ac-4044-f7a3-1f67cf3efced"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>description</th>\n",
       "      <th>stars</th>\n",
       "      <th>type</th>\n",
       "      <th>id</th>\n",
       "      <th>similarity_score</th>\n",
       "      <th>rank</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Article №: Keith Ti5820 ● FUNCTIONALLY SIMPLE AND ELEGANT --- Much of our design inspiration comes directly from outdoor adventurers and travelers. We seek out innovative solutions for their needs with the belief that less is more and that simplicity yields elegance. ● STRAIGHTFORWARDLY VERSATILE AND MULTI-PURPOSE --- We design our products to be used in ways expected and unexpected to save weight and space when every ounce counts. ● ENVIRONMENTALLY FRIENDLY AND HEALTHY --- We strive to mini...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>product</td>\n",
       "      <td>B01NAEP534</td>\n",
       "      <td>0.829024</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Inituitive Breath-o-prene ErgoFrom Headgear, Simplus Headgear Med/Lrg</td>\n",
       "      <td>4.7</td>\n",
       "      <td>product</td>\n",
       "      <td>B01DJGEERQ</td>\n",
       "      <td>0.793512</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Adidas logo above back right pocket\\nUPF 50+ for Sun protection</td>\n",
       "      <td>4.7</td>\n",
       "      <td>product</td>\n",
       "      <td>B078W8M374</td>\n",
       "      <td>0.787995</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>We specialize in wall and tabletop frames, document frames, shadow boxes, organizer box, and other home and office decor. We pride ourselves on creating classic, and meaningful products that will make your home or office shine as well as providing items that are ready to give as giffts straight out of the box. Time Does Not Wait for You! Yesterday will not be called again. We always inadvertently remembered the good moments of the past. Let your photographs and pictures seize the day, for fl...</td>\n",
       "      <td>4.5</td>\n",
       "      <td>product</td>\n",
       "      <td>B089SQX1R1</td>\n",
       "      <td>0.785493</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>SPECIFICATIONS -Material : Stainless Steel-Thickness : 4mm -Finish : Matte Black -Installation Method : Screw fixing   Package Includes  2 x Brackets  8 X Screws  Buy from Alise  Solid metal construction, 4mm-thick, heavy duty design  Solid stainless steel materials, Choose 4mm-Thick stainless steel brackets,Durable and rust-free  Exclusive Brand, Production and Marketing Integration,Quality Assurance,We choose the best materials, the most exquisite product technology, and the best quality s...</td>\n",
       "      <td>4.6</td>\n",
       "      <td>product</td>\n",
       "      <td>B07L879PDS</td>\n",
       "      <td>0.782095</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Low-profile design offers comfort and security\\nHigh-tech memory foam comfortably conforms to your neck and shoulder, antimicrobial material allows moisture to dissipate so you stay cool\\nSlimlock secures to your guitar or bass without the bulk and rigidity of a conventional connector\\nFully adjustable 37\"-48\" (94cm-122cm)\\nMade in the USA, Date First Available: April 2, 2007, Customer Reviews: 5.0 out of 5 stars 2 ratings 5.0 out of 5 stars, Size: Regular, Item model number: 8202162, ASIN: ...</td>\n",
       "      <td>5.0</td>\n",
       "      <td>product</td>\n",
       "      <td>B000G1KDJ6</td>\n",
       "      <td>0.778213</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>These Can Coolers Are White Blank Sublimation 12 Oz 3MM Insulated Neoprene Material, They Are Foldable And Waterproof., Insulated Neoprene, Date First Available: April 8, 2021, ASIN: B091V8YM2S, Package Dimensions: 7.6 x 7.24 x 1.65 inches, Customer Reviews: 4.6 out of 5 stars 250 ratings 4.6 out of 5 stars, Item Weight: 8.4 ounces</td>\n",
       "      <td>4.6</td>\n",
       "      <td>product</td>\n",
       "      <td>B091V8YM2S</td>\n",
       "      <td>0.777513</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>SKILLED-RIDER SCOOTER: The next generation of the award-winning YBIKE GLX scooter. With its modern 3 wheel Lean-and-Steer design, the GLX PRO is the best option for older and more skilled riders.\\nADJUSTABLE HANDLEBAR: As riders develop better coordination, endurance, and overall strength, the GLX PRO grows with them. The adjustable handlebar extends from 28 to 32.5 inches above the deck.\\nFAST &amp; SMOOTH: Features larger 125mm front wheels, wide fiber-reinforced non-slip ABS deck, and composi...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>product</td>\n",
       "      <td>B00BTTFK5Q</td>\n",
       "      <td>0.777121</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Adidas logo above back right pocket\\nUPF 50+ for Sun protection\\nStretch waistband for mobility and comfort</td>\n",
       "      <td>4.6</td>\n",
       "      <td>product</td>\n",
       "      <td>B079HGN1YT</td>\n",
       "      <td>0.776733</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>About Funkrin:    Our brand focuses on the thermal insulation series, providing consumers with full-scene, high-quality and differentiated products that are built to last. The thermal insulation series includes lunch boxes, food jar, coffee mug, sports water bottle and other products, to covers consumers' daily thermal insulation needs.Why Choose Us:1.WIDE USE:18oz capacity is ideal for outdoor, travel, party, coffee, water, wine, beverages, milk, etc2. Each tumbler includes a sliding lid, w...</td>\n",
       "      <td>4.3</td>\n",
       "      <td>product</td>\n",
       "      <td>B093DVT1FL</td>\n",
       "      <td>0.773049</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           description  \\\n",
       "0  Article №: Keith Ti5820 ● FUNCTIONALLY SIMPLE AND ELEGANT --- Much of our design inspiration comes directly from outdoor adventurers and travelers. We seek out innovative solutions for their needs with the belief that less is more and that simplicity yields elegance. ● STRAIGHTFORWARDLY VERSATILE AND MULTI-PURPOSE --- We design our products to be used in ways expected and unexpected to save weight and space when every ounce counts. ● ENVIRONMENTALLY FRIENDLY AND HEALTHY --- We strive to mini...   \n",
       "1                                                                                                                                                                                                                                                                                                                                                                                                                                                Inituitive Breath-o-prene ErgoFrom Headgear, Simplus Headgear Med/Lrg   \n",
       "2                                                                                                                                                                                                                                                                                                                                                                                                                                                      Adidas logo above back right pocket\\nUPF 50+ for Sun protection   \n",
       "3  We specialize in wall and tabletop frames, document frames, shadow boxes, organizer box, and other home and office decor. We pride ourselves on creating classic, and meaningful products that will make your home or office shine as well as providing items that are ready to give as giffts straight out of the box. Time Does Not Wait for You! Yesterday will not be called again. We always inadvertently remembered the good moments of the past. Let your photographs and pictures seize the day, for fl...   \n",
       "4  SPECIFICATIONS -Material : Stainless Steel-Thickness : 4mm -Finish : Matte Black -Installation Method : Screw fixing   Package Includes  2 x Brackets  8 X Screws  Buy from Alise  Solid metal construction, 4mm-thick, heavy duty design  Solid stainless steel materials, Choose 4mm-Thick stainless steel brackets,Durable and rust-free  Exclusive Brand, Production and Marketing Integration,Quality Assurance,We choose the best materials, the most exquisite product technology, and the best quality s...   \n",
       "5  Low-profile design offers comfort and security\\nHigh-tech memory foam comfortably conforms to your neck and shoulder, antimicrobial material allows moisture to dissipate so you stay cool\\nSlimlock secures to your guitar or bass without the bulk and rigidity of a conventional connector\\nFully adjustable 37\"-48\" (94cm-122cm)\\nMade in the USA, Date First Available: April 2, 2007, Customer Reviews: 5.0 out of 5 stars 2 ratings 5.0 out of 5 stars, Size: Regular, Item model number: 8202162, ASIN: ...   \n",
       "6                                                                                                                                                                        These Can Coolers Are White Blank Sublimation 12 Oz 3MM Insulated Neoprene Material, They Are Foldable And Waterproof., Insulated Neoprene, Date First Available: April 8, 2021, ASIN: B091V8YM2S, Package Dimensions: 7.6 x 7.24 x 1.65 inches, Customer Reviews: 4.6 out of 5 stars 250 ratings 4.6 out of 5 stars, Item Weight: 8.4 ounces   \n",
       "7  SKILLED-RIDER SCOOTER: The next generation of the award-winning YBIKE GLX scooter. With its modern 3 wheel Lean-and-Steer design, the GLX PRO is the best option for older and more skilled riders.\\nADJUSTABLE HANDLEBAR: As riders develop better coordination, endurance, and overall strength, the GLX PRO grows with them. The adjustable handlebar extends from 28 to 32.5 inches above the deck.\\nFAST & SMOOTH: Features larger 125mm front wheels, wide fiber-reinforced non-slip ABS deck, and composi...   \n",
       "8                                                                                                                                                                                                                                                                                                                                                                                                          Adidas logo above back right pocket\\nUPF 50+ for Sun protection\\nStretch waistband for mobility and comfort   \n",
       "9  About Funkrin:    Our brand focuses on the thermal insulation series, providing consumers with full-scene, high-quality and differentiated products that are built to last. The thermal insulation series includes lunch boxes, food jar, coffee mug, sports water bottle and other products, to covers consumers' daily thermal insulation needs.Why Choose Us:1.WIDE USE:18oz capacity is ideal for outdoor, travel, party, coffee, water, wine, beverages, milk, etc2. Each tumbler includes a sliding lid, w...   \n",
       "\n",
       "   stars     type          id  similarity_score  rank  \n",
       "0    4.8  product  B01NAEP534          0.829024     0  \n",
       "1    4.7  product  B01DJGEERQ          0.793512     1  \n",
       "2    4.7  product  B078W8M374          0.787995     2  \n",
       "3    4.5  product  B089SQX1R1          0.785493     3  \n",
       "4    4.6  product  B07L879PDS          0.782095     4  \n",
       "5    5.0  product  B000G1KDJ6          0.778213     5  \n",
       "6    4.6  product  B091V8YM2S          0.777513     6  \n",
       "7    4.8  product  B00BTTFK5Q          0.777121     7  \n",
       "8    4.6  product  B079HGN1YT          0.776733     8  \n",
       "9    4.3  product  B093DVT1FL          0.773049     9  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positive_results = app.query(\n",
    "    query,\n",
    "    natural_query=\"good design products\",\n",
    "    limit=10,\n",
    ")\n",
    "sl.PandasConverter.to_pandas(positive_results)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The parameters extracted by the NLQ solution can be accessed using the `metadata.search_params` attribute of the `Result` object the query returns. Note, that these values are not necessarily absolutely stable if run multiple times as a result of being extracted by an LLM."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'description_weight': 1.0,\n",
       " 'rating_maximizer_weight': 1.0,\n",
       " 'query_text': 'good design products',\n",
       " 'limit': 10,\n",
       " 'natural_query': 'good design products',\n",
       " 'filter_by_type': 'product',\n",
       " 'radius_param': None,\n",
       " 'description_similar_clause_weight': 1.0}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "positive_results.metadata.search_params"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If the param is not set explicitly, it will get extracted from the query if possible."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>description</th>\n",
       "      <th>stars</th>\n",
       "      <th>type</th>\n",
       "      <th>id</th>\n",
       "      <th>similarity_score</th>\n",
       "      <th>rank</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>*, , Traducción en español del cuento clásico ganador de la Medalla Caldecott, Un día de nieve . Es un día de nieve y Pedro sale a explorar. Mientras pasea entre montones de nieve apilada y observa a los niños grandes jugar a tirarse bolas gigantes--descubre los surcos que dejan sus pies en la nieve espesa y lo divertido que es hacer figuras de ángeles en la nieve. \"This translation of Keats's original Caldecott Medal winner captures the physical and emotional experiences of Peter and his de...</td>\n",
       "      <td>4.9</td>\n",
       "      <td>book</td>\n",
       "      <td>0140543635</td>\n",
       "      <td>0.756564</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>The petite shell-shaped cakes known as madeleines are versatile, pretty, and absolutely delicious. Made famous by Marcel Proust in his novel In Search of Lost Time , this classic French treat is now loved the world over. Beautifully illustrated and lovingly researched, Madeleines features recipes for an incredible variety of flavors and combinations, including such decadent desserts as Dark Chocolate Espresso Madeleines, savory appetizers like Pesto and Pine Nut Madeleines, and showstoppers ...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>1594747407</td>\n",
       "      <td>0.749755</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Embark on a desert adventure with illustrator Geninne D Zlatkis. Crafted as a love letter to the desert, Zlatkis's collection of charming illustrations feature some of her favorite crafty creatures and natural treasures all found in her desert home. Her passion for this magnificent and wild place will inspire you to explore your own color palette and bring the illustrations to vivid life. By the creator of the best-selling Feathered Friends wall calendar. 40 original full-page images illustr...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>1631363174</td>\n",
       "      <td>0.749599</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Mass Market Paperback – January 1, 1995</td>\n",
       "      <td>5.0</td>\n",
       "      <td>book</td>\n",
       "      <td>B0011EU0OA</td>\n",
       "      <td>0.745495</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NATIONAL BESTSELLER Alexandra Morton has been called \"the Jane Goodall of Canada\" because of her passionate thirty-year fight to save British Columbia's wild salmon. Her account of that fight is both inspiring in its own right and a roadmap of resistance. Alexandra Morton came north from California in the early 1980s, following her first love--the northern resident orca. In remote Echo Bay, in the Broughton Archipelago, she found the perfect place to settle into all she had ever dreamed of: ...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>0735279667</td>\n",
       "      <td>0.745189</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>“An absorbing, generous, ravishing book by a high priestess of you-have-to-read-this prose.\" ―Cheryl Strayed, author of Wild Pam Houston, an \"early master of the art of rendering fiercely independent, brilliant women in love with the wrong men\" (Sarah Norris, Barnes &amp; Noble Review ), delivers a novel that whisks us from one breathtaking precipice to the next. Along the way, we unravel the story of Pam (a character not unlike the author), a fearless traveler aiming to leave her metaphorical b...</td>\n",
       "      <td>4.0</td>\n",
       "      <td>book</td>\n",
       "      <td>0393343480</td>\n",
       "      <td>0.743844</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>From the writer of the award-winning food blog Harvest and Honey, including Saveur Best Blog finalist Showcasing the flavors and modern cooking techniques of Appalachia and the Blue Ridge Mountains: With over 70 delectable recipes and 80 stunning photographs organized by seasons, Smoke, Roots, Mountain, Harvest is an evocative cookbook rooted in Appalachian ingredients and flavors that takes readers and cooks deep into the heart and soul of America. Lauren McDuffie uses modern cooking techni...</td>\n",
       "      <td>4.5</td>\n",
       "      <td>book</td>\n",
       "      <td>1452168768</td>\n",
       "      <td>0.736398</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>The original, best-selling \"Rock\" book keeps on rolling, now celebrating its 5th anniversary! This modern-day classic follows 14 lovable rocks (and one wise little ladybug) on a heartwarming and hilarious journey, universally loved by children, parents and teachers alike. From zippy little pebbles to big strong boulders, the rock friends get together to play and roll around their favorite hill, only to find that one of their friends, Ricky, can't roll with them. Unlike all of the other rocks...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>0578198037</td>\n",
       "      <td>0.734977</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>The world’s most unique guide to alcohol-free drinks.  Over 250 pages, featuring nearly 100 delicious, flavorful recipes. Brimming with beautiful, large-format photography and illustrations. Countless insights about beverage design from acclaimed Chef Grant Achatz and his brilliant culinary team. Printed and bound using cutting-edge fine art technologies. Measuring approximately 8½\" x 11½\" x 1\", weighing over 6 lbs. with a tactile hard cover.  This culinary approach to beverages will be equa...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>1733008837</td>\n",
       "      <td>0.726857</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>All five of the Court of Thorns and Roses hardcovers with the new series look in a luxe box set perfect for the holiday season. Passionate, violent, sexy and daring ... A true page-turner - USA TODAY on A Court of Thorns and Roses Feyre is a huntress. The skin of a wolf would bring enough gold to feed her sisters for a month. But the life of a magical creature comes at a steep price, and Feyre has just killed the wrong wolf ... Follow Feyre's journey into the dangerous, alluring world of the...</td>\n",
       "      <td>4.9</td>\n",
       "      <td>book</td>\n",
       "      <td>1635577713</td>\n",
       "      <td>0.726486</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           description  \\\n",
       "0  *, , Traducción en español del cuento clásico ganador de la Medalla Caldecott, Un día de nieve . Es un día de nieve y Pedro sale a explorar. Mientras pasea entre montones de nieve apilada y observa a los niños grandes jugar a tirarse bolas gigantes--descubre los surcos que dejan sus pies en la nieve espesa y lo divertido que es hacer figuras de ángeles en la nieve. \"This translation of Keats's original Caldecott Medal winner captures the physical and emotional experiences of Peter and his de...   \n",
       "1  The petite shell-shaped cakes known as madeleines are versatile, pretty, and absolutely delicious. Made famous by Marcel Proust in his novel In Search of Lost Time , this classic French treat is now loved the world over. Beautifully illustrated and lovingly researched, Madeleines features recipes for an incredible variety of flavors and combinations, including such decadent desserts as Dark Chocolate Espresso Madeleines, savory appetizers like Pesto and Pine Nut Madeleines, and showstoppers ...   \n",
       "2  Embark on a desert adventure with illustrator Geninne D Zlatkis. Crafted as a love letter to the desert, Zlatkis's collection of charming illustrations feature some of her favorite crafty creatures and natural treasures all found in her desert home. Her passion for this magnificent and wild place will inspire you to explore your own color palette and bring the illustrations to vivid life. By the creator of the best-selling Feathered Friends wall calendar. 40 original full-page images illustr...   \n",
       "3                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Mass Market Paperback – January 1, 1995   \n",
       "4  NATIONAL BESTSELLER Alexandra Morton has been called \"the Jane Goodall of Canada\" because of her passionate thirty-year fight to save British Columbia's wild salmon. Her account of that fight is both inspiring in its own right and a roadmap of resistance. Alexandra Morton came north from California in the early 1980s, following her first love--the northern resident orca. In remote Echo Bay, in the Broughton Archipelago, she found the perfect place to settle into all she had ever dreamed of: ...   \n",
       "5  “An absorbing, generous, ravishing book by a high priestess of you-have-to-read-this prose.\" ―Cheryl Strayed, author of Wild Pam Houston, an \"early master of the art of rendering fiercely independent, brilliant women in love with the wrong men\" (Sarah Norris, Barnes & Noble Review ), delivers a novel that whisks us from one breathtaking precipice to the next. Along the way, we unravel the story of Pam (a character not unlike the author), a fearless traveler aiming to leave her metaphorical b...   \n",
       "6  From the writer of the award-winning food blog Harvest and Honey, including Saveur Best Blog finalist Showcasing the flavors and modern cooking techniques of Appalachia and the Blue Ridge Mountains: With over 70 delectable recipes and 80 stunning photographs organized by seasons, Smoke, Roots, Mountain, Harvest is an evocative cookbook rooted in Appalachian ingredients and flavors that takes readers and cooks deep into the heart and soul of America. Lauren McDuffie uses modern cooking techni...   \n",
       "7  The original, best-selling \"Rock\" book keeps on rolling, now celebrating its 5th anniversary! This modern-day classic follows 14 lovable rocks (and one wise little ladybug) on a heartwarming and hilarious journey, universally loved by children, parents and teachers alike. From zippy little pebbles to big strong boulders, the rock friends get together to play and roll around their favorite hill, only to find that one of their friends, Ricky, can't roll with them. Unlike all of the other rocks...   \n",
       "8  The world’s most unique guide to alcohol-free drinks.  Over 250 pages, featuring nearly 100 delicious, flavorful recipes. Brimming with beautiful, large-format photography and illustrations. Countless insights about beverage design from acclaimed Chef Grant Achatz and his brilliant culinary team. Printed and bound using cutting-edge fine art technologies. Measuring approximately 8½\" x 11½\" x 1\", weighing over 6 lbs. with a tactile hard cover.  This culinary approach to beverages will be equa...   \n",
       "9  All five of the Court of Thorns and Roses hardcovers with the new series look in a luxe box set perfect for the holiday season. Passionate, violent, sexy and daring ... A true page-turner - USA TODAY on A Court of Thorns and Roses Feyre is a huntress. The skin of a wolf would bring enough gold to feed her sisters for a month. But the life of a magical creature comes at a steep price, and Feyre has just killed the wrong wolf ... Follow Feyre's journey into the dangerous, alluring world of the...   \n",
       "\n",
       "   stars  type          id  similarity_score  rank  \n",
       "0    4.9  book  0140543635          0.756564     0  \n",
       "1    4.7  book  1594747407          0.749755     1  \n",
       "2    4.8  book  1631363174          0.749599     2  \n",
       "3    5.0  book  B0011EU0OA          0.745495     3  \n",
       "4    4.8  book  0735279667          0.745189     4  \n",
       "5    4.0  book  0393343480          0.743844     5  \n",
       "6    4.5  book  1452168768          0.736398     6  \n",
       "7    4.8  book  0578198037          0.734977     7  \n",
       "8    4.8  book  1733008837          0.726857     8  \n",
       "9    4.9  book  1635577713          0.726486     9  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "book_filtered_query_result = app.query(query, natural_query=\"acclaimed books about adventures\", limit=10)\n",
    "sl.PandasConverter.to_pandas(book_filtered_query_result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'description_weight': 1.0,\n",
       " 'rating_maximizer_weight': 1.0,\n",
       " 'query_text': 'adventures',\n",
       " 'limit': 10,\n",
       " 'natural_query': 'acclaimed books about adventures',\n",
       " 'filter_by_type': 'book',\n",
       " 'radius_param': None,\n",
       " 'description_similar_clause_weight': 1.0}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "book_filtered_query_result.metadata.search_params"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If we set `rating` (or any `Param`) explicitly, it will not be modified based on the natural language query. The solution will extract all information from the query it can, but it will reconcile it with the explicitly set values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>description</th>\n",
       "      <th>stars</th>\n",
       "      <th>type</th>\n",
       "      <th>id</th>\n",
       "      <th>similarity_score</th>\n",
       "      <th>rank</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>110 pages perfect binding 60# offset paper practical size DIN A5 durable softcover Read more, , Paperback – March 8, 2019</td>\n",
       "      <td>4.5</td>\n",
       "      <td>book</td>\n",
       "      <td>1799146049</td>\n",
       "      <td>0.785638</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>One of the most influential works of this century, The Myth of Sisyphus and Other Essays is a crucial exposition of existentialist thought. Influenced by works such as Don Juan and the novels of Kafka, these essays begin with a meditation on suicide, the question of living or not living in a universe devoid of order or meaning. With lyric eloquence, Albert Camus brilliantly posits a way out of despair, reaffirming the value of personal existence, and the possibility of life lived with dignit...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>B07HLQQZ3L</td>\n",
       "      <td>0.760927</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>The original, best-selling \"Rock\" book keeps on rolling, now celebrating its 5th anniversary! This modern-day classic follows 14 lovable rocks (and one wise little ladybug) on a heartwarming and hilarious journey, universally loved by children, parents and teachers alike. From zippy little pebbles to big strong boulders, the rock friends get together to play and roll around their favorite hill, only to find that one of their friends, Ricky, can't roll with them. Unlike all of the other rocks...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>0578198037</td>\n",
       "      <td>0.757853</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Newly Revised &amp; Updated! The Eleventh Edition of America’s Best-Selling Dictionary defines the current, active vocabulary of American English and is updated on an ongoing basis. Features more than 225,000 definitions and over 42,000 usage examples. Includes newly added words and meanings across a variety of fields including technology, entertainment, health, science, and society. Special sections include A Handbook of Style, Foreign Words and Phrases, Biographical Names, and Geographical Nam...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>0877798079</td>\n",
       "      <td>0.753675</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>The world’s most unique guide to alcohol-free drinks.  Over 250 pages, featuring nearly 100 delicious, flavorful recipes. Brimming with beautiful, large-format photography and illustrations. Countless insights about beverage design from acclaimed Chef Grant Achatz and his brilliant culinary team. Printed and bound using cutting-edge fine art technologies. Measuring approximately 8½\" x 11½\" x 1\", weighing over 6 lbs. with a tactile hard cover.  This culinary approach to beverages will be equa...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>1733008837</td>\n",
       "      <td>0.752495</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>The Complete Guide to High School English Literature brings an extraordinary and comprehensive learning experience to all high school students in the field of English language and literature through skill-by-skill instructions and case studies. Whether you are seeking a complete grammar guide or step-by-step techniques to write exemplary essays, The Complete Guide to High School English Literature meets your needs. Amirsaman Zahabioun, the author of The Complete Guide to High School English ...</td>\n",
       "      <td>5.0</td>\n",
       "      <td>book</td>\n",
       "      <td>1793074933</td>\n",
       "      <td>0.749798</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Written by leading experts in language and cognition, this groundbreaking behavior analysis textbook brings the study of verbal behavior into the 21st century with cutting-edge research. Students and clinicians in the burgeoning field of applied behavior analysis will find the theoretical foundation they need to effectively help the increasingly diverse clients seeking their services.The origins of behavior analysis can be traced to the pioneering work of B.F. Skinner. Skinner’s fundamental ...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>B07YWGXW5X</td>\n",
       "      <td>0.747655</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Great product!, , Now featuring a new introduction by Dr. M. Scott Peck, the twenty-fifth anniversary edition of the classic bestseller The Road Less Traveled, celebrated by The Washington Post as “not just a book but a spontaneous act of generosity.” Perhaps no book in this generation has had a more profound impact on our intellectual and spiritual lives than The Road Less Traveled. With sales of more than seven million copies in the United States and Canada, and translations into more than...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>0743243153</td>\n",
       "      <td>0.747432</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Are you missing something in your life? Do you know that there is more for you? Are the stresses of this world causing you anxiety? Are you struggling to connect with God on a regular basis? Would you like to work on deepening your faith but you just don’t know how? Do you already have a connection with God, but you're looking to enhance your daily communication with Him? The Anchored with Purpose Faith Journal is a tool designed to help you with all of these. This quarterly journal has been...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>1701496100</td>\n",
       "      <td>0.743098</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>TITAN, , Focusing on the beautiful artwork of Guerrilla Games’ Horizon Zero Dawn this is an in-depth insight into a world as dangerous as it is beautiful. The Art of Horizon Zero Dawn is the ultimate gallery of the hotly anticipated new IP from Guerrilla Games ( Killzone series). It focuses on the stunning artwork used to develop the game, and includes over 300 images, sketches, and concept art, commentary throughout from the artists and creators. This is an in-depth insight into a world as ...</td>\n",
       "      <td>4.9</td>\n",
       "      <td>book</td>\n",
       "      <td>1785653636</td>\n",
       "      <td>0.740999</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           description  \\\n",
       "0                                                                                                                                                                                                                                                                                                                                                                                            110 pages perfect binding 60# offset paper practical size DIN A5 durable softcover Read more, , Paperback – March 8, 2019   \n",
       "1  One of the most influential works of this century, The Myth of Sisyphus and Other Essays is a crucial exposition of existentialist thought. Influenced by works such as Don Juan and the novels of Kafka, these essays begin with a meditation on suicide, the question of living or not living in a universe devoid of order or meaning. With lyric eloquence, Albert Camus brilliantly posits a way out of despair, reaffirming the value of personal existence, and the possibility of life lived with dignit...   \n",
       "2  The original, best-selling \"Rock\" book keeps on rolling, now celebrating its 5th anniversary! This modern-day classic follows 14 lovable rocks (and one wise little ladybug) on a heartwarming and hilarious journey, universally loved by children, parents and teachers alike. From zippy little pebbles to big strong boulders, the rock friends get together to play and roll around their favorite hill, only to find that one of their friends, Ricky, can't roll with them. Unlike all of the other rocks...   \n",
       "3  Newly Revised & Updated! The Eleventh Edition of America’s Best-Selling Dictionary defines the current, active vocabulary of American English and is updated on an ongoing basis. Features more than 225,000 definitions and over 42,000 usage examples. Includes newly added words and meanings across a variety of fields including technology, entertainment, health, science, and society. Special sections include A Handbook of Style, Foreign Words and Phrases, Biographical Names, and Geographical Nam...   \n",
       "4  The world’s most unique guide to alcohol-free drinks.  Over 250 pages, featuring nearly 100 delicious, flavorful recipes. Brimming with beautiful, large-format photography and illustrations. Countless insights about beverage design from acclaimed Chef Grant Achatz and his brilliant culinary team. Printed and bound using cutting-edge fine art technologies. Measuring approximately 8½\" x 11½\" x 1\", weighing over 6 lbs. with a tactile hard cover.  This culinary approach to beverages will be equa...   \n",
       "5  The Complete Guide to High School English Literature brings an extraordinary and comprehensive learning experience to all high school students in the field of English language and literature through skill-by-skill instructions and case studies. Whether you are seeking a complete grammar guide or step-by-step techniques to write exemplary essays, The Complete Guide to High School English Literature meets your needs. Amirsaman Zahabioun, the author of The Complete Guide to High School English ...   \n",
       "6  Written by leading experts in language and cognition, this groundbreaking behavior analysis textbook brings the study of verbal behavior into the 21st century with cutting-edge research. Students and clinicians in the burgeoning field of applied behavior analysis will find the theoretical foundation they need to effectively help the increasingly diverse clients seeking their services.The origins of behavior analysis can be traced to the pioneering work of B.F. Skinner. Skinner’s fundamental ...   \n",
       "7  Great product!, , Now featuring a new introduction by Dr. M. Scott Peck, the twenty-fifth anniversary edition of the classic bestseller The Road Less Traveled, celebrated by The Washington Post as “not just a book but a spontaneous act of generosity.” Perhaps no book in this generation has had a more profound impact on our intellectual and spiritual lives than The Road Less Traveled. With sales of more than seven million copies in the United States and Canada, and translations into more than...   \n",
       "8  Are you missing something in your life? Do you know that there is more for you? Are the stresses of this world causing you anxiety? Are you struggling to connect with God on a regular basis? Would you like to work on deepening your faith but you just don’t know how? Do you already have a connection with God, but you're looking to enhance your daily communication with Him? The Anchored with Purpose Faith Journal is a tool designed to help you with all of these. This quarterly journal has been...   \n",
       "9  TITAN, , Focusing on the beautiful artwork of Guerrilla Games’ Horizon Zero Dawn this is an in-depth insight into a world as dangerous as it is beautiful. The Art of Horizon Zero Dawn is the ultimate gallery of the hotly anticipated new IP from Guerrilla Games ( Killzone series). It focuses on the stunning artwork used to develop the game, and includes over 300 images, sketches, and concept art, commentary throughout from the artists and creators. This is an in-depth insight into a world as ...   \n",
       "\n",
       "   stars  type          id  similarity_score  rank  \n",
       "0    4.5  book  1799146049          0.785638     0  \n",
       "1    4.7  book  B07HLQQZ3L          0.760927     1  \n",
       "2    4.8  book  0578198037          0.757853     2  \n",
       "3    4.7  book  0877798079          0.753675     3  \n",
       "4    4.8  book  1733008837          0.752495     4  \n",
       "5    5.0  book  1793074933          0.749798     5  \n",
       "6    4.8  book  B07YWGXW5X          0.747655     6  \n",
       "7    4.7  book  0743243153          0.747432     7  \n",
       "8    4.8  book  1701496100          0.743098     8  \n",
       "9    4.9  book  1785653636          0.740999     9  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "book_explicitly_filtered_results = app.query(\n",
    "    query,\n",
    "    natural_query=(\"Products with high durability. Filter for products.\"),\n",
    "    # notice how we explicitly override what is in the natural_query, and that is reflected in the results\n",
    "    filter_by_type=\"book\",\n",
    "    limit=10,\n",
    ")\n",
    "\n",
    "sl.PandasConverter.to_pandas(book_explicitly_filtered_results)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Using .with_vector clauses\n",
    "\n",
    "Using this clause with natural language requires the user to reference the id of the item explicitly."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "with_vector_results = app.query(\n",
    "    with_vector_query,\n",
    "    natural_query=\"similar books like B07HLQQZ3L\",\n",
    "    limit=10,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'description_weight': 1.0,\n",
       " 'rating_maximizer_weight': 1.0,\n",
       " 'product_id': 'B07HLQQZ3L',\n",
       " 'natural_query': 'similar books like B07HLQQZ3L',\n",
       " 'limit': 10,\n",
       " 'radius_param': None,\n",
       " 'with_vector_id_weight_param': 1.0}"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# notice how review_id is filled with the specified id\n",
    "with_vector_results.metadata.search_params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>description</th>\n",
       "      <th>stars</th>\n",
       "      <th>type</th>\n",
       "      <th>id</th>\n",
       "      <th>similarity_score</th>\n",
       "      <th>rank</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>One of the most influential works of this century, The Myth of Sisyphus and Other Essays is a crucial exposition of existentialist thought. Influenced by works such as Don Juan and the novels of Kafka, these essays begin with a meditation on suicide, the question of living or not living in a universe devoid of order or meaning. With lyric eloquence, Albert Camus brilliantly posits a way out of despair, reaffirming the value of personal existence, and the possibility of life lived with dignit...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>B07HLQQZ3L</td>\n",
       "      <td>0.996534</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Used Book in Good Condition, , Widely regarded as one of the most profound critics of our time, René Girard has pursued a powerful line of inquiry across the fields of the humanities and the social sciences. His theories, which the French press has termed \"l'hypothèse girardienne,\" have sparked interdisciplinary, even international, controversy. In The Scapegoat , Girard applies his approach to \"texts of persecution,\" documents that recount phenomena of collective violence from the standpoin...</td>\n",
       "      <td>4.6</td>\n",
       "      <td>book</td>\n",
       "      <td>0801839173</td>\n",
       "      <td>0.792681</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Used Book in Good Condition, , 2012 Reprint of Original Three Volume s First Published from 1905-1907. Exact facsimile of the original edition, not reproduced with Optical Recognition Software. This is a collection of Crowley's early esoteric writings and poetry and comprise the first collected edition of his writings. Aleister Crowley, born Edward Alexander Crowley, and also known as both Frater Perdurabo and The Great Beast, was an influential English occultist, mystic, ceremonial magician...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>1614272794</td>\n",
       "      <td>0.768150</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Written by leading experts in language and cognition, this groundbreaking behavior analysis textbook brings the study of verbal behavior into the 21st century with cutting-edge research. Students and clinicians in the burgeoning field of applied behavior analysis will find the theoretical foundation they need to effectively help the increasingly diverse clients seeking their services.The origins of behavior analysis can be traced to the pioneering work of B.F. Skinner. Skinner’s fundamental ...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>book</td>\n",
       "      <td>B07YWGXW5X</td>\n",
       "      <td>0.760974</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Mass Market Paperback – January 1, 1995</td>\n",
       "      <td>5.0</td>\n",
       "      <td>book</td>\n",
       "      <td>B0011EU0OA</td>\n",
       "      <td>0.751635</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Great product!, , Now featuring a new introduction by Dr. M. Scott Peck, the twenty-fifth anniversary edition of the classic bestseller The Road Less Traveled, celebrated by The Washington Post as “not just a book but a spontaneous act of generosity.” Perhaps no book in this generation has had a more profound impact on our intellectual and spiritual lives than The Road Less Traveled. With sales of more than seven million copies in the United States and Canada, and translations into more than...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>book</td>\n",
       "      <td>0743243153</td>\n",
       "      <td>0.751624</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>*, , Traducción en español del cuento clásico ganador de la Medalla Caldecott, Un día de nieve . Es un día de nieve y Pedro sale a explorar. Mientras pasea entre montones de nieve apilada y observa a los niños grandes jugar a tirarse bolas gigantes--descubre los surcos que dejan sus pies en la nieve espesa y lo divertido que es hacer figuras de ángeles en la nieve. \"This translation of Keats's original Caldecott Medal winner captures the physical and emotional experiences of Peter and his de...</td>\n",
       "      <td>4.9</td>\n",
       "      <td>book</td>\n",
       "      <td>0140543635</td>\n",
       "      <td>0.750470</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>The Complete Guide to High School English Literature brings an extraordinary and comprehensive learning experience to all high school students in the field of English language and literature through skill-by-skill instructions and case studies. Whether you are seeking a complete grammar guide or step-by-step techniques to write exemplary essays, The Complete Guide to High School English Literature meets your needs. Amirsaman Zahabioun, the author of The Complete Guide to High School English ...</td>\n",
       "      <td>5.0</td>\n",
       "      <td>book</td>\n",
       "      <td>1793074933</td>\n",
       "      <td>0.749953</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Church congregations all across the United States are searching for the magic bullet, the secret to attracting people, growing their membership and their cultural relevance. They are looking for the right program, or the right environment, or the right features to help bring people back into the pews. With all of this searching for the right answer, they're missing what's right in front of them: Word and Sacrament. The ancient church saw martyrdom as an honor. Today, we cower in corners, bic...</td>\n",
       "      <td>4.6</td>\n",
       "      <td>book</td>\n",
       "      <td>0758666446</td>\n",
       "      <td>0.735314</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Do you like sarcasm and dark humor? Oppose communism? This anti socialist meme design is for you. There SJW out there who don't get dark humor, sarcastic jokes &amp; don't realize the failure of socialism in CCCP. Educate them with this anti communism meme.\\nSoviet Union under Lenin and Stalin were oppressive towards their people. Food shortages and red famine were a result of the socialist ideology in the USSR. This dark humor anti communist anti socialist Stalin design is a great way to show p...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>product</td>\n",
       "      <td>B07F5RX8CR</td>\n",
       "      <td>0.729629</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           description  \\\n",
       "0  One of the most influential works of this century, The Myth of Sisyphus and Other Essays is a crucial exposition of existentialist thought. Influenced by works such as Don Juan and the novels of Kafka, these essays begin with a meditation on suicide, the question of living or not living in a universe devoid of order or meaning. With lyric eloquence, Albert Camus brilliantly posits a way out of despair, reaffirming the value of personal existence, and the possibility of life lived with dignit...   \n",
       "1  Used Book in Good Condition, , Widely regarded as one of the most profound critics of our time, René Girard has pursued a powerful line of inquiry across the fields of the humanities and the social sciences. His theories, which the French press has termed \"l'hypothèse girardienne,\" have sparked interdisciplinary, even international, controversy. In The Scapegoat , Girard applies his approach to \"texts of persecution,\" documents that recount phenomena of collective violence from the standpoin...   \n",
       "2  Used Book in Good Condition, , 2012 Reprint of Original Three Volume s First Published from 1905-1907. Exact facsimile of the original edition, not reproduced with Optical Recognition Software. This is a collection of Crowley's early esoteric writings and poetry and comprise the first collected edition of his writings. Aleister Crowley, born Edward Alexander Crowley, and also known as both Frater Perdurabo and The Great Beast, was an influential English occultist, mystic, ceremonial magician...   \n",
       "3  Written by leading experts in language and cognition, this groundbreaking behavior analysis textbook brings the study of verbal behavior into the 21st century with cutting-edge research. Students and clinicians in the burgeoning field of applied behavior analysis will find the theoretical foundation they need to effectively help the increasingly diverse clients seeking their services.The origins of behavior analysis can be traced to the pioneering work of B.F. Skinner. Skinner’s fundamental ...   \n",
       "4                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Mass Market Paperback – January 1, 1995   \n",
       "5  Great product!, , Now featuring a new introduction by Dr. M. Scott Peck, the twenty-fifth anniversary edition of the classic bestseller The Road Less Traveled, celebrated by The Washington Post as “not just a book but a spontaneous act of generosity.” Perhaps no book in this generation has had a more profound impact on our intellectual and spiritual lives than The Road Less Traveled. With sales of more than seven million copies in the United States and Canada, and translations into more than...   \n",
       "6  *, , Traducción en español del cuento clásico ganador de la Medalla Caldecott, Un día de nieve . Es un día de nieve y Pedro sale a explorar. Mientras pasea entre montones de nieve apilada y observa a los niños grandes jugar a tirarse bolas gigantes--descubre los surcos que dejan sus pies en la nieve espesa y lo divertido que es hacer figuras de ángeles en la nieve. \"This translation of Keats's original Caldecott Medal winner captures the physical and emotional experiences of Peter and his de...   \n",
       "7  The Complete Guide to High School English Literature brings an extraordinary and comprehensive learning experience to all high school students in the field of English language and literature through skill-by-skill instructions and case studies. Whether you are seeking a complete grammar guide or step-by-step techniques to write exemplary essays, The Complete Guide to High School English Literature meets your needs. Amirsaman Zahabioun, the author of The Complete Guide to High School English ...   \n",
       "8  Church congregations all across the United States are searching for the magic bullet, the secret to attracting people, growing their membership and their cultural relevance. They are looking for the right program, or the right environment, or the right features to help bring people back into the pews. With all of this searching for the right answer, they're missing what's right in front of them: Word and Sacrament. The ancient church saw martyrdom as an honor. Today, we cower in corners, bic...   \n",
       "9  Do you like sarcasm and dark humor? Oppose communism? This anti socialist meme design is for you. There SJW out there who don't get dark humor, sarcastic jokes & don't realize the failure of socialism in CCCP. Educate them with this anti communism meme.\\nSoviet Union under Lenin and Stalin were oppressive towards their people. Food shortages and red famine were a result of the socialist ideology in the USSR. This dark humor anti communist anti socialist Stalin design is a great way to show p...   \n",
       "\n",
       "   stars     type          id  similarity_score  rank  \n",
       "0    4.7     book  B07HLQQZ3L          0.996534     0  \n",
       "1    4.6     book  0801839173          0.792681     1  \n",
       "2    4.7     book  1614272794          0.768150     2  \n",
       "3    4.8     book  B07YWGXW5X          0.760974     3  \n",
       "4    5.0     book  B0011EU0OA          0.751635     4  \n",
       "5    4.7     book  0743243153          0.751624     5  \n",
       "6    4.9     book  0140543635          0.750470     6  \n",
       "7    5.0     book  1793074933          0.749953     7  \n",
       "8    4.6     book  0758666446          0.735314     8  \n",
       "9    4.7  product  B07F5RX8CR          0.729629     9  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# the most similar review to review 130 is itself.\n",
    "sl.PandasConverter.to_pandas(with_vector_results)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Filling Params with default values\n",
    "\n",
    "Now let's run a natural language query on a `Query` that contains a `Param` that has a default value. If not mentioned by the user, the `Param` will have it's user defined `default` value."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>description</th>\n",
       "      <th>stars</th>\n",
       "      <th>type</th>\n",
       "      <th>id</th>\n",
       "      <th>similarity_score</th>\n",
       "      <th>rank</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Article №: Keith Ti5820 ● FUNCTIONALLY SIMPLE AND ELEGANT --- Much of our design inspiration comes directly from outdoor adventurers and travelers. We seek out innovative solutions for their needs with the belief that less is more and that simplicity yields elegance. ● STRAIGHTFORWARDLY VERSATILE AND MULTI-PURPOSE --- We design our products to be used in ways expected and unexpected to save weight and space when every ounce counts. ● ENVIRONMENTALLY FRIENDLY AND HEALTHY --- We strive to mini...</td>\n",
       "      <td>4.8</td>\n",
       "      <td>product</td>\n",
       "      <td>B01NAEP534</td>\n",
       "      <td>0.792297</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Infused with Argan Oil\\nThermal Protector\\nWeightless Formula</td>\n",
       "      <td>4.6</td>\n",
       "      <td>product</td>\n",
       "      <td>B075FBD7CM</td>\n",
       "      <td>0.789568</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Ready to wear. Arrives with a finished hemmed to avoid extra tailoring.\\nTailored around your body's natural silhouette.\\nTapered leg in a stretch comfort fabric for ease of movement.\\nGreat for your 9-5 work week, a night out, or traveling. Wrink resistant engineered fabric.\\nMultiple colors for any occasion. Pairs well with a button down and blazer.</td>\n",
       "      <td>4.4</td>\n",
       "      <td>product</td>\n",
       "      <td>B00O104CHC</td>\n",
       "      <td>0.787733</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Beautiful and contemporary design complements any décor, with large display and warm backlight for easy viewing even from across the room\\nEarly start mode ensures the desired temperature is reached by the programmed time, making for a comfortable home whenever you need it\\n7-Day programmability: program each day individually with up to 4 programming periods. This thermostat is not compatible with base board heaters (or other line voltage heating), multi-stage heating or cooling systems, or ...</td>\n",
       "      <td>4.4</td>\n",
       "      <td>product</td>\n",
       "      <td>B01D16HAFW</td>\n",
       "      <td>0.787419</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Breathable mesh lining\\nPerformance suede leather and mesh upper\\nBellows, closed-cell foam tongue keeps moisture and debris out\\nMerrell M Select FIT.ECO+ blended EVA contoured footbed with added zonal arch and heel support\\nVibram TC5+ sole</td>\n",
       "      <td>4.6</td>\n",
       "      <td>product</td>\n",
       "      <td>B01HFPQII0</td>\n",
       "      <td>0.785246</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>70 Precise Settings for your perfect grind - from coarse for Cold Brew and French Press, to fine for Espresso. Easy reference brew method icons help to easily match the grind size to the brew method.\\nAutomatic Smart Dosing Technology to seelect the cups or shots desired, grind-time is adjusted accordingly for perfect dosing, regardless of grind size or brew method.\\nBuilt-In Adjustable Portafilter Holder to grind directly into 54-mm or 58-mm portafilters, perfect for espresso making.\\nAnti-...</td>\n",
       "      <td>4.5</td>\n",
       "      <td>product</td>\n",
       "      <td>B08JH6K5PY</td>\n",
       "      <td>0.785223</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Quick-dry knit fabric with UPF 50 for sun protection\\nFull coverage\\nSun-protective design\\nTankini-style top\\nLong-sleeve design</td>\n",
       "      <td>4.6</td>\n",
       "      <td>product</td>\n",
       "      <td>B07HL3WRG5</td>\n",
       "      <td>0.784935</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Per-key RGB backlighting and a 19-zone LightEdge across the top of the keyboard delivers dynamic and vibrant lighting effects with near-limitless customization.\\nPrecision-molded 1. 5mm thick 104/105-key PBT double-shot keycap set resists wear, fading, and shine through years of gaming.\\nGain an in-game advantage with six dedicated macro keys, fully programmable for complex macros and key remaps, or swap to the included S-key keycaps and program special streaming commands through Elgato Stre...</td>\n",
       "      <td>4.7</td>\n",
       "      <td>product</td>\n",
       "      <td>B082GRKQYF</td>\n",
       "      <td>0.784544</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>UA Storm technology delivers an element battling, highly water resistant finish\\nTough, abrasion resistant bottom panel\\nFoam reinforced panels add protection\\nSoft lined laptop sleeve—holds up to 15\" MacBook Pro or similarly sized laptop\\nWater repellent front valuables pocket to keep your stuff safe</td>\n",
       "      <td>4.8</td>\n",
       "      <td>product</td>\n",
       "      <td>B01MF9C5VG</td>\n",
       "      <td>0.784429</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Our best foundation for long wear, Double Wear is oil-free and oil-controlling.\\nThis transfer-resistant and waterproof foundation formula lasts in hot and humid weather.\\nUnifies uneven skintone and covers imperfections with a natural, matte finish.\\nKeeps up with your busy day. Put it on once and don’t think twice.\\nSPF 10 - Dermatologist tested, non-acnegenic, won't clog pores.</td>\n",
       "      <td>4.7</td>\n",
       "      <td>product</td>\n",
       "      <td>B00B5QWFCO</td>\n",
       "      <td>0.783980</td>\n",
       "      <td>9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           description  \\\n",
       "0  Article №: Keith Ti5820 ● FUNCTIONALLY SIMPLE AND ELEGANT --- Much of our design inspiration comes directly from outdoor adventurers and travelers. We seek out innovative solutions for their needs with the belief that less is more and that simplicity yields elegance. ● STRAIGHTFORWARDLY VERSATILE AND MULTI-PURPOSE --- We design our products to be used in ways expected and unexpected to save weight and space when every ounce counts. ● ENVIRONMENTALLY FRIENDLY AND HEALTHY --- We strive to mini...   \n",
       "1                                                                                                                                                                                                                                                                                                                                                                                                                                                        Infused with Argan Oil\\nThermal Protector\\nWeightless Formula   \n",
       "2                                                                                                                                                    Ready to wear. Arrives with a finished hemmed to avoid extra tailoring.\\nTailored around your body's natural silhouette.\\nTapered leg in a stretch comfort fabric for ease of movement.\\nGreat for your 9-5 work week, a night out, or traveling. Wrink resistant engineered fabric.\\nMultiple colors for any occasion. Pairs well with a button down and blazer.   \n",
       "3  Beautiful and contemporary design complements any décor, with large display and warm backlight for easy viewing even from across the room\\nEarly start mode ensures the desired temperature is reached by the programmed time, making for a comfortable home whenever you need it\\n7-Day programmability: program each day individually with up to 4 programming periods. This thermostat is not compatible with base board heaters (or other line voltage heating), multi-stage heating or cooling systems, or ...   \n",
       "4                                                                                                                                                                                                                                                                   Breathable mesh lining\\nPerformance suede leather and mesh upper\\nBellows, closed-cell foam tongue keeps moisture and debris out\\nMerrell M Select FIT.ECO+ blended EVA contoured footbed with added zonal arch and heel support\\nVibram TC5+ sole   \n",
       "5  70 Precise Settings for your perfect grind - from coarse for Cold Brew and French Press, to fine for Espresso. Easy reference brew method icons help to easily match the grind size to the brew method.\\nAutomatic Smart Dosing Technology to seelect the cups or shots desired, grind-time is adjusted accordingly for perfect dosing, regardless of grind size or brew method.\\nBuilt-In Adjustable Portafilter Holder to grind directly into 54-mm or 58-mm portafilters, perfect for espresso making.\\nAnti-...   \n",
       "6                                                                                                                                                                                                                                                                                                                                                                                    Quick-dry knit fabric with UPF 50 for sun protection\\nFull coverage\\nSun-protective design\\nTankini-style top\\nLong-sleeve design   \n",
       "7  Per-key RGB backlighting and a 19-zone LightEdge across the top of the keyboard delivers dynamic and vibrant lighting effects with near-limitless customization.\\nPrecision-molded 1. 5mm thick 104/105-key PBT double-shot keycap set resists wear, fading, and shine through years of gaming.\\nGain an in-game advantage with six dedicated macro keys, fully programmable for complex macros and key remaps, or swap to the included S-key keycaps and program special streaming commands through Elgato Stre...   \n",
       "8                                                                                                                                                                                                      UA Storm technology delivers an element battling, highly water resistant finish\\nTough, abrasion resistant bottom panel\\nFoam reinforced panels add protection\\nSoft lined laptop sleeve—holds up to 15\" MacBook Pro or similarly sized laptop\\nWater repellent front valuables pocket to keep your stuff safe   \n",
       "9                                                                                                                      Our best foundation for long wear, Double Wear is oil-free and oil-controlling.\\nThis transfer-resistant and waterproof foundation formula lasts in hot and humid weather.\\nUnifies uneven skintone and covers imperfections with a natural, matte finish.\\nKeeps up with your busy day. Put it on once and don’t think twice.\\nSPF 10 - Dermatologist tested, non-acnegenic, won't clog pores.   \n",
       "\n",
       "   stars     type          id  similarity_score  rank  \n",
       "0    4.8  product  B01NAEP534          0.792297     0  \n",
       "1    4.6  product  B075FBD7CM          0.789568     1  \n",
       "2    4.4  product  B00O104CHC          0.787733     2  \n",
       "3    4.4  product  B01D16HAFW          0.787419     3  \n",
       "4    4.6  product  B01HFPQII0          0.785246     4  \n",
       "5    4.5  product  B08JH6K5PY          0.785223     5  \n",
       "6    4.6  product  B07HL3WRG5          0.784935     6  \n",
       "7    4.7  product  B082GRKQYF          0.784544     7  \n",
       "8    4.8  product  B01MF9C5VG          0.784429     8  \n",
       "9    4.7  product  B00B5QWFCO          0.783980     9  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "default_filter_results = app.query(\n",
    "    query_with_default_filter,\n",
    "    natural_query=\"high versatility, high ratings\",\n",
    "    limit=10,\n",
    ")\n",
    "sl.PandasConverter.to_pandas(default_filter_results)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As we can see even though the user said nothing about the `filter_by_type` Param, nevertheless results are filtered for products as that is a `default` value of that `Param` defined previously in `query_with_default_filter`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'description_weight': 1.0,\n",
       " 'rating_maximizer_weight': 1.0,\n",
       " 'query_text': 'high versatility',\n",
       " 'limit': 10,\n",
       " 'natural_query': 'high versatility, high ratings',\n",
       " 'filter_by_type': 'product',\n",
       " 'radius_param': None,\n",
       " 'description_similar_clause_weight': 1.0}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "default_filter_results.metadata.search_params"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "collapsed_sections": [
    "3nckbUhPVHic"
   ],
   "gpuType": "T4",
   "provenance": []
  },
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
